package com.tuling.test.annotation;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
public class UserService implements InitializingBean {

	//@Autowired
	private OrderService orderService;

	private User admin;

	public UserService() {
		System.out.println("1");
	}

/*	public void setOrderService(OrderService orderService) {
		this.orderService = orderService;
	}*/

	public UserService(@Qualifier("orderService2") OrderService orderService){ //Map<beanName,bean对象>
		this.orderService = orderService;
		System.out.println("2");
	}

	@Autowired(required = true)
	public UserService(OrderService orderService,OrderService orderService1){
		this.orderService = orderService;
		System.out.println("3");
	}

	@PostConstruct
	public void a(){
		//mysql--->User对象-->admin

	}

	@Override
	public void afterPropertiesSet() throws Exception {

	}

	public void test(){
		System.out.println(orderService);
	}
}
